<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>eval()函数</title>
    <script type="text/javascript">
        jsonText = "[{\"deptno\":10,\"dname\":\"教学研发部\",\"loc\":\"北京\"}," +
            "{\"deptno\":20,\"dname\":\"财务部\",\"loc\":\"上海\"}," +
            "{\"deptno\":30,\"dname\":\"时市场部\",\"loc\":\"广州\"}]";
        jsonObject = eval("("+jsonText+")"); // 文本转为JSON对象
        for (x = 0; x < jsonObject.length; x ++) {
            console.log("【部门信息】编号：" + jsonObject[x].deptno + "、名称：" + jsonObject[x].dname + "、位置：" + jsonObject[x].loc);
        }
    </script>
</head>
<body>
</body>
</html>
